<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <child1></child1>
    </div>
    <script src="./vue.js"></script>
    <script>
        const child1 = {
            inject: ['name'],
            template: `
                <div>
                    这是子组件一
                    {{name}}
                </div>
            `,
            data() {
                return {
                    msg: ''
                }
            },
            created() {
                // console.log(this.$parent.newMsg)
                // this.msg = this.$parent.newMsg
                console.log(this.name)

            }
        }

        Vue.component('child1', child1)
        new Vue({
            el: "#app",
            provide: {
                name: "张三"
            },
            data:{
                newMsg: 'hello world'
            }
        })
    </script>
</body>
</html>